{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Constructing a Workflow (Lattice)\n",
    "\n",
    "Lattices are workflows comprised of a sequence of tasks. In your Python code, a lattice is a function with the `@lattice` decorator.\n",
    "\n",
    "To construct a lattice, do the following.\n",
    "\n",
    "### Prerequisites\n",
    "\n",
    "Construct one or more electrons with which to compose the lattice:\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import covalent as ct\n",
    "\n",
    "@ct.electron\n",
    "def quadrature(x, y):\n",
    "    return sqrt(x**2 + y**2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Procedure\n",
    "\n",
    "1. Write a function that uses one or more electrons to process the data.\n",
    "2. Attach the `@lattice` decorator.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "@ct.lattice\n",
    "def quad_workflow(x, y):\n",
    "    return quadrature(x, y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### See Also\n",
    "\n",
    "[Constructing an Electron](./construct_electron.ipynb)\n",
    "\n",
    "[Adding Electrons to Lattices](./add_electron_to_lattice.ipynb)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
